//
//  ConnectDeviceRequest.m
//  TestGizWits
//
//  Created by JM on 15/11/18.
//  Copyright © 2015年 JM. All rights reserved.
//

#import "ConnectDeviceRequest.h"

@implementation ConnectDeviceRequest

- (void)didRealRequest {
    
    //如果没有设置委托，则设置委托到当前使用的Cocoa类所对应的实例
    self.DY_device.delegate = self;
    
    //需要开发者自行把 uid 和 token 换成实际的值
    [self.DY_device login:self.DY_uid token:self.DY_token];
    
}


- (void)XPGWifiDevice:(XPGWifiDevice *)device didLogin:(int)result {
    if(result == XPGWifiError_NONE) {
         self.DY_device.delegate = nil;
        
        ConnectDeviceResponse* response = [ConnectDeviceResponse response];
//        response.DY_wifiSDK = wifiSDK;!!!!!!!没有这个，代理也不同
        response.DY_device = device;
        self.block(response,nil);
    }
    else
    {
        self.block(nil,[NSError dy_errorWithErrCode:result]);
    }
    [super superHandelResponse];
    //todo shezhi回原先的观察着
}

- (void)dealloc {
    self.DY_device.delegate = nil;
}


@end

@implementation ConnectDeviceResponse

@end
